home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / code / zuck / launchit.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-10-06  |  2.4 KB  |  83 lines

  1. VERSION 2.00
  2. Begin Form LaunchBackground 
  3.    Caption         =   "Launch Background Program"
  4.    ClientHeight    =   2505
  5.    ClientLeft      =   2865
  6.    ClientTop       =   2970
  7.    ClientWidth     =   5205
  8.    Height          =   2910
  9.    Left            =   2805
  10.    LinkTopic       =   "Form2"
  11.    ScaleHeight     =   2505
  12.    ScaleWidth      =   5205
  13.    Top             =   2625
  14.    Width           =   5325
  15.    Begin CommandButton cmdClose 
  16.       Caption         =   "Close"
  17.       Height          =   435
  18.       Left            =   3120
  19.       TabIndex        =   3
  20.       Top             =   1740
  21.       Width           =   1215
  22.    End
  23.    Begin CommandButton cmdLaunch 
  24.       Caption         =   "Launch"
  25.       Height          =   435
  26.       Left            =   1320
  27.       TabIndex        =   2
  28.       Top             =   1740
  29.       Width           =   1155
  30.    End
  31.    Begin Timer Timer1 
  32.       Enabled         =   0   'False
  33.       Interval        =   500
  34.       Left            =   360
  35.       Top             =   1740
  36.    End
  37.    Begin CheckBox Check1 
  38.       Caption         =   "Launch Hidden"
  39.       Height          =   315
  40.       Left            =   360
  41.       TabIndex        =   1
  42.       Top             =   900
  43.       Value           =   1  'Checked
  44.       Width           =   3435
  45.    End
  46.    Begin TextBox Text1 
  47.       Height          =   315
  48.       Left            =   360
  49.       TabIndex        =   0
  50.       Text            =   "command.com"
  51.       Top             =   360
  52.       Width           =   4095
  53.    End
  54. Option Explicit
  55. Dim modulehandle%
  56. Sub cmdClose_Click ()
  57.     Unload Me
  58. End Sub
  59. Sub cmdLaunch_Click ()
  60.     Dim hideflag%
  61.     If check1.Value = 1 Then hideflag% = SW_MINIMIZE Else hideflag% = SW_NORMAL
  62.     ' Note, the hidden flag does not override the setting
  63.     ' in the PIF file.  Use the PIF file setting to
  64.     ' create a DOS window that works in the background.
  65.     modulehandle% = WinExec(Text1.Text, hideflag%)
  66.     If modulehandle% <= 32 Then
  67.         MsgBox "Not a valid executable"
  68.         Exit Sub
  69.     End If
  70.     cmdLaunch.Enabled = False
  71.     cmdClose.Enabled = False
  72.     timer1.Enabled = True
  73. End Sub
  74. Sub Form_Load ()
  75. End Sub
  76. Sub Timer1_Timer ()
  77.     If GetModuleUsage(modulehandle%) <> 0 Then Exit Sub
  78.     modulehandle% = 0
  79.     cmdLaunch.Enabled = True
  80.     cmdClose.Enabled = True
  81.     timer1.Enabled = False
  82. End Sub
  83.